<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RadioField
 *
 * @author Comp
 */

define('DOMROOT', dirname(dirname(dirname(__FILE__))));

require_once DOMROOT.'/classes/FormsAPI/FormField.php';
require_once DOMROOT.'/classes/FormsAPI/RadioHTMLHandler.php';

class RadioField extends FormField{
  
    private $_HTMLHandler;
    private $_required  =   false;

    public function __construct($_name) {

        parent::setName($_name);
        
        $this->_HTMLHandler =   new RadioHTMLHandler();
        
    }

    
    public function setValue($_value) {
        
        parent::setValue($_value);
    }
    
    public function getValue() {
     
        return parent::getValue();
        
    }
    
    public  function    isRequired( ){

            
            $this->_required    =   TRUE;
    }

    public function validate(){
        
          //override
        
        if($this->_required){
            
            if(!parent::getValue())
            parent::setDefaultError("* Mandatory");
        }
    }
    
    public  function    getHTMLHandler(){
        
        return $this->_HTMLHandler;
    }
    
    public function render(){
        
        return $this->getHTMLHandler()->render();
       
    }
    
}

?>
